{% extends 'base.html' %}
{% block title %}
    网站首页
{% endblock %}
{% block content %}
    <h1>{{ data.title }}</h1>
    <hr>
    <ul class="news-list">
        {% for item in data.article_list %}
            <li>
                {# 在模板中定义变量 #}
{#                {% set url = "/news_detail?id=%s&title=%s&content=%s"%(item.id,item.title,item.content) %}  #}
                {% set url = "/news_detail?id={id}&title={title}&content={content}".format(id=item.id,title=item.title,content=item.content) %}

                <a href={{ url }}>
                    {{ item.id }}-{{ item.title }}-{{ item.content }}--{{ item.author.username }}
                </a>
            </li>
        {% endfor %}
    </ul>
    <style>
    .news-list{
        list-style: none;
    }
    .news-list>li{
        padding: 10px;
    }
    .news-list>li:hover{
        background-color: #f0f0f0;
    }
    .news-list>li>a{
        text-decoration: none;
        color:#333;
    }
    </style>
{% endblock %}
